import React from 'react'
import {
    BrowserRouter as Router,
    Switch,
    Route,
    Link
} from 'react-router-dom'

class Login extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            userName: '',
            userPassword: ''
        }
    }

    componentDidMount(){
        console.log('componentDidMount')
    }
    render() {
        return (
            <div>
                <input value={this.state.userName} onChange={this.inputValChangeName} />
                <input value={this.state.userPassword} onChange={this.inputValChangePwd} />
                <button onClick={this.userLogin.bind(this)}>登录</button>
                {/* <Link to='/home'>Login</Link> */}
                </div>)
    }
   
    inputValChangeName= (e) => {
        this.setState({
            userName: e.target.value
        });
        console.log(e.target.value)
    }


    inputValChangePwd=(e) =>{
        this.setState({
            userPassword: e.target.value
        });
    }
    userLogin() {
        let urseName = this.state.userName
        console.log(urseName)
        // 跳转
        this.props.history.push({
            pathname:'./home',
            state:{
            'userId':123
            }
        })

    }

}


export default Login
